﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_Ortak_Menu : System.Web.UI.UserControl
{

    SiteMapMenus eMenuToLoad = SiteMapMenus.NotSet;
    public SiteMapMenus MenuToLoad
    {
        get { return eMenuToLoad; }
        set
        {
            eMenuToLoad = value;
            this.MenuBind();
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        this.MenuBind();
    }

    private void MenuBind()
    {
        Menu1.DataSource = GetMenuDataSource(eMenuToLoad, Server.MapPath("~"));
        if (eMenuToLoad != SiteMapMenus.NotSet)
            Menu1.DataBind();
    }

    XmlDataSource GetMenuDataSource(SiteMapMenus menu, string serverMapPath)
    {
        XmlDataSource objData = new XmlDataSource();
        objData.XPath = "siteMap/siteMapNode";
        switch (menu)
        {
            case SiteMapMenus.TKB:
                objData.DataFile = serverMapPath + @"\SiteMap\TKB.sitemap";
                break;
        }
        objData.DataBind();
        return objData;
    }
}
